package com.smh.a06exerciseDemo2;

import java.io.File;

public class Test6 {
    public static void main(String[] args) {

        File file = new File("day25-code\\src\\com\\smh\\File");
        long size = method(file);
        System.out.println(size);
        //统计文件夹大小

    }

    public static long method(File file) {
        if (file.isFile()) {
            return file.length();
        } else {
            long sum = 0;
            File[] files = file.listFiles();
            if (files != null) {
                for (File file1 : files) {
                    sum += method(file1);
                }
            }
            return sum;
        }
    }
}
